 use "LAPS-Carrots or Sticks.dta", clear
 
 encode ccode, gen(id)
encode subreg, gen(subreg_id)

xtset id year

 
//Figure 4

pca dem efi dos_vote
predict alignUS
gen alignUS2=alignUS+4.764098
replace alignUS2= alignUS2/7.181398

egen median_alignUS2=median(alignUS2), by(ccode)
graph box alignUS2, over(ccode, sort(median_alignUS2)) ytitle("Index of Alignment with the US") 

// Models Table 2
xtpcse Disbursements_Economic_next Disbursements_Economic c.exports_china_gdp_var##c.alignUS2 c.cgit_total_gdp_var##c.alignUS2 c.china_aid_gdp_var##c.alignUS2 gdpcap exports_us_gdp i.subreg_id if  year>2011
outreg2 using results.doc, word replace

xtpcse Disbursements_Economic_next Disbursements_Economic c.exports_china_gdp_var##c.alignUS2 gdpcap exports_us_gdp i.subreg_id if  year>2011
outreg2 using results.doc, word append

xtpcse Disbursements_Economic_next Disbursements_Economic  c.cgit_total_gdp_var##c.alignUS2 gdpcap exports_us_gdp i.subreg_id if  year>2011
outreg2 using results.doc, word append

xtpcse Disbursements_Economic_next Disbursements_Economic  c.china_aid_gdp_var##c.alignUS2 gdpcap exports_us_gdp i.subreg_id if  year>2011
outreg2 using results.doc, word append

xtpcse disb_eco_pol_next disb_eco_pol c.exports_china_gdp_var##c.alignUS2 c.cgit_total_gdp_var##c.alignUS2 c.china_aid_gdp_var##c.alignUS2 gdpcap exports_us_gdp i.subreg_id if  year>2011
outreg2 using results.doc, word append

xtpcse us_disb_next us_disb c.exports_china_gdp_var##c.alignUS2 c.cgit_total_gdp_var##c.alignUS2 c.china_aid_gdp_var##c.alignUS2 gdpcap exports_us_gdp i.subreg_id if  year>2011
outreg2 using results.doc, word append


// Figure 5

xtpcse Disbursements_Economic_next Disbursements_Economic c.exports_china_gdp_var##c.alignUS2 c.cgit_total_gdp_var##c.alignUS2 c.china_aid_gdp_var##c.alignUS2 gdpcap exports_us_gdp i.subreg_id if  year>2011

margins, dydx(exports_china_gdp_var) at(alignUS=(0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 ))
marginsplot, recast(line) recastci(rarea) yline(0, lcolor(darkgray)) ciopt(color(gray%40)) plotopts(lcolor(black)) level(95) graphregion(col(white)) xlabel(0(0.2) 1) ytitle("Effects on US Economic Assistance") xtitle("Alignment with the US") title("Trade") subtitle("Annual Variation", span) saving("trade", replace)

margins, dydx(cgit_total_gdp_var) at(alignUS=(0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 ))
marginsplot, recast(line) recastci(rarea) yline(0, lcolor(darkgray)) ciopt(color(gray%40)) plotopts(lcolor(black)) level(95) graphregion(col(white)) xlabel(0(0.2) 1) ytitle("Effects on US Economic Assistance") xtitle("Alignment with the US") ytitle("") title("Investment") subtitle("Annual Variation", span) saving("invest", replace) 



margins, dydx(china_aid_gdp_var) at(alignUS=(0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 ))
marginsplot, recast(line) recastci(rarea) yline(0, lcolor(darkgray)) ciopt(color(gray%40)) plotopts(lcolor(black)) level(95) graphregion(col(white)) xlabel(0(0.2) 1) ytitle("Effects on US Economic Assistance") xtitle("Alignment with the US") ytitle("") title("Development Assistance") subtitle("Annual Variation", span)  saving("aid", replace)

gr combine trade.gph invest.gph aid.gph, cols(3) rows(1) graphregion(col(white)) iscale(*1.6) xsize(6) ysize(2.5) ycommon









